package com.xintouyun.medicine.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xintouyun.medicine.entity.News;
import com.xintouyun.medicine.service.NewsService;
import com.xintouyun.medicine.service.impl.NewsServiceImpl;

@WebServlet("/detailnews")
public class DetailNewsServlet extends HttpServlet{
	@Override
    public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException{

    	String id = request.getParameter("nid");
    	Integer nid = Integer.parseInt(id);
    	
    	NewsService newsService = new NewsServiceImpl();
    	
    	News theNews = newsService.get(nid);
    	
    	
    	request.setAttribute("theNews", theNews);
    	request.getRequestDispatcher("newscontent.jsp").forward(request, response);
    }
	
	@Override
    public void doPost(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException{
    	this.doGet(request, response);
    }
}
